/**
 * @file      : main.c
 * @brief     : 程序入口文件
 * @author    : huenrong (huenrong1028@gmail.com)
 * @date      : 2020-10-22 15:47:12
 *
 * @copyright : Copyright (c) 2020  胡恩荣
 *
 */

#include <stdio.h>
#include <stdint.h>

#include "./pwm/pwm.h"

// PWM定义
#define PWM_CHIP_0 0

int main(int argc, char *argv[])
{
    int ret = -1;

    // 导出设备
    ret = pwm_export(PWM_CHIP_0);
    printf("pwm_export ret = %d\n", ret);

    // 使能PWM
    ret = pwm_enable(PWM_CHIP_0);
    printf("pwm_enable ret = %d\n", ret);

    // 设置周期
    ret = pwm_set_period(PWM_CHIP_0, 50000);
    printf("pwm_set_period ret = %d\n", ret);

    // 设置占空比
    ret = pwm_set_duty_cycle(PWM_CHIP_0, 10000);
    printf("pwm_set_duty_cycle ret = %d\n", ret);

    // 取消导出
    ret = pwm_unexport(PWM_CHIP_0);
    printf("pwm_unexport ret = %d\n", ret);

    return 0;
}
